//
//  MyMessageTableCell.m
//  MIDI
//
//  Created by E.M.Game on 15/9/11.
//  Copyright (c) 2015年 QXSX. All rights reserved.
//

#import "MyMessageTableCell.h"
#import "AppConfig.h"
#import "CommFunc.h"

@interface MyMessageTableCell ()

@end

@implementation MyMessageTableCell

- (void)awakeFromNib
{
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//    
//    [formatter setDateFormat:@"YY-MM-dd"];
//    
//    NSString *timestamp = [formatter stringFromDate:[NSDate date]];
//    
//    [self.dateLabel setText:timestamp];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"MyMessageTableCell";
    MyMessageTableCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        cell = [[[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil]firstObject];
        
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
    
    return cell;
}

-(int)getHeight
{
    int height = [CommFunc sizeWithString:self.messageLabel.text
                        font:[UIFont fontWithName:@"Hiragino Sans GB" size:12]
                         max:CGSizeMake(self.messageLabel.frame.size.width, MAXFLOAT)].height;
    
    if (height <= 0)
        return 84;
    else
    {
        height = self.messageLabel.frame.origin.y + height + 17;
        return height;
    }
    
    return 0;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    for (UIView *subView in self.subviews)
    {
        if ([NSStringFromClass([subView class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"])
        {
            UIView *del = ((UIView *)[subView.subviews firstObject]);
            del.backgroundColor = UIColorRGBA(19, 208, 202, 1);
        }
    }
}

@end
